<?php

$deId = $_GET['pid'] > 0 ? $_GET['pid'] : $_POST['deId'];

if ($deId < 1 || $deId == '') {

    header('Location: categorie_list.php');
    exit;
}

error_reporting(E_ALL);
include_once('../controller/includes/db_access.php');

if ((isset($_POST['action']) ? $_POST['action'] : (isset($_GET['action']) ? $_GET['action'] : '')) == 'multiple') {

    $product_id = $_POST['pro_id'];

    $q = new Query;
    $q
            ->delete_from('`product`')
        
           
            ->where_equal_to(
                    array(
                        '`product`.`product_id`' => $product_id
                    )
            )
            ->limit(1);

    $result = $q->run();
    $categorie_id = $q->get_deleted();
    if (!($result && $categorie_id > 0)){
        
        $Error = 'No category found.' . "\n";
        
    } else 
        {

           header('Location: product_list.php');  
           
        }
}
?>


<?php
if (isset($_GET['pid'])) {

    $id = $_GET['pid'];
    $q = new Query;
    $q
            ->select('*'
            )
            ->from('`product`')
            ->where_equal_to(
                    array(
                        '`product`.`product_id`' => $id,
                    )
    );

    $result = $q->run();

    if (!($result > 0)) {
        $Error = 'No product found.' . "\n";
    } else {
        $rows_pro = mysql_fetch_object($result);
    }
}
?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" href="styles/screen.css" type="text/css" charset="utf-8" media="screen" />

        <script src="js/jquery.js" type="text/javascript"></script>
        <script src="js/jquery.validate.js" type="text/javascript"></script>

    </head>
    <body>
        <table width="900" border="0" cellspacing="5" cellpadding="5">
            <thead>
                <tr>
                    <th colspan="3"><?php include_once('../controller/includes/header.php'); ?></th>

                </tr>
            </thead>
            <tbody> 
            <form name="form1" enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" class="cmxform" id="signupForm" >
                <input type="hidden" name="action" value="multiple" />
                <input type="hidden" name="pro_id" value="<?php echo $_GET['pid']; ?>" />
                <tr>
                    <td width="10%" valign="top"> </td>
                    <td width="50%" valign="top"><font color="red"><?php
if (isset($Error)) {
    echo '  Error: ' . $Error;
}
?></font> </td>
                    <td width="40%" valign="top"></td>
                </tr>
                <tr>
                    <td>Product Categorie</td>
                    <td>
                     <?php
                            $q = new Query;
                            $q->select('*')
                                    ->from('`categorieen`')
                                    ->order_by(array('`categorieen`.`categorie` ASC',))
                                    ->run();

                            $result = $q->run();
                            $count = $q->get_selected_count();

                            if (!($result && $count > 0)) {
                                echo 'No users found.' . "\n";
                            } else {
                                $rows = mysql_fetch_object($result);
                                echo $rows->categorie; }
                         ?>
                    </td>
                    <td></td>
                </tr>

                <tr>
                    <td>Naam: </td>
                    <td><?php echo $rows_pro->naam; ?></td>
                    <td></td>
                </tr>
                <tr>
                    <td>merk: </td>
                    <td><?php echo $rows_pro->merk; ?></td>
                    <td></td>
                </tr>
                <tr>
                    <td>type: </td>
                    <td><?php echo $rows_pro->type; ?></td>
                    <td> </td>
                </tr>
                <tr>
                    <td>Beschrijving</td>
                    <td>
<?php echo $rows_pro->descr; ?>
                      </td>
                    <td></td>
                </tr>
                <tr>
                    <td  valign="top">
                        <p>Foto 1<br /><br /></p>

                        <p>Foto 2<br /><br /></p>

                        <p>Foto 3</p>

                    </td>
                    <td  valign="top">
                        
                        <p class="button"></p>
                    </td>
                    <td></td>
                </tr>

                <tr>
                    <td>Aantal</td>
                    <td><?php echo $rows_pro->aantal; ?></td>
                    <td></td>
                </tr>
                <tr>
                    <td>Huur Prijs (incl BTW)</td>
                    <td><?php echo $rows_pro->huurprijs; ?></td>
                    <td></td>
                </tr>
                <tr>
                    <td>
                        <p>Manual<br /><br /></p>
                        <p>Technical</p>
                    </td>
                    <td>
                        
                    </td>
                    <td></td>
                </tr>

                <tr>
                    <td >Link</td>
                    <td><?php echo $rows_pro->url; ?></td>
                    <td></td>
                </tr>
                <tr>
                    <td>Link naam</td>
                    <td><?php echo $rows_pro->url_name; ?></td>
                    <td></td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>Beschikbaar</td>
                    <td>
                      <?php echo $rows_pro->aktief == 'Y' ? 'Ja' : ' Nee';?></td>
                    <td></td>
                </tr>
                <tr>
                    <td></td>
                    <td></td>
                    <td><input type="submit" value="delete" name="save" size="20" /></td>
                </tr>   
            </form>
        </tbody>
    </table>

</body>
</html>
